import multiprocessing
import time

"""
多进程的设计:
面向对象
"""

# 继承Process需要重写run方法
class MyProcess(multiprocessing.Process):
    def __init__(self,name,delay,count):
        # 参数初始化
        super().__init__(name=name)
        self.__delay = delay  # 保存属性
        self.__count = count


    def run(self) -> None:
        for id in range(self.__count):
            print("run id[{}]--[name]{}--[pid]{}".format(id,
                                                     multiprocessing.current_process().name,
                                                     multiprocessing.current_process().pid,
                                                     ))
            time.sleep(self.__delay)

def main():
    pass

if __name__ == '__main__':
    for i in range(3):
        p = MyProcess(name='测试进程{}'.format(i),delay=1,count=10)
        p.start()
